const express = require('express');
const router = express.Router();


function getTimes(req,res,next){
    res.Times = new Date().getTime();
    next();
}

//router.use([前缀,]中间件函数):使用中间件
// router.use(getTimes);
router.use('/student',getTimes);


//设计路由：

// router.get('/api/teacher',(req,res)=>{

    router.get('/teacher',(req,res)=>{

    res.send(`老师界面:${res.Times}`);
});


// router.get('/api/student',(req,res)=>{
    router.get('/student',(req,res)=>{

    res.send(`学生界面...${res.Times}`);
});


//404错误处理中间件：
router.use('*',(req,res,next)=>{
     res.send(`404错误`);
});


module.exports = router;